import './App.scss'
import { Router, Switch, Route, Redirect } from 'react-router-dom'
import Login from '@/pages/Login/Login'
import Layout from '@/pages/Layout/Layout'
import ProfileEdit from './pages/Profile/Edit'
import PrivateRoute from './components/PrivateRoute'
import history from './utils/history'
import Chat from './pages/Profile/Chat/Chat'
function App () {
  return (
    <div className="app">
      <Router history={history}>
        <Switch>
          {/* <Redirect exact from='/' to='/home' /> */}
          <Route path="/" exact render={() => <Redirect to="/home" />} />

          <Route path="/login" component={Login} />

          <Route path="/home">
            <Layout />
          </Route>

          <PrivateRoute path="/profile/edit">
            <ProfileEdit />
          </PrivateRoute>

          <PrivateRoute path="/chat">
            <Chat />
          </PrivateRoute>

          {/* <Route path="/profile/edit" render={()=>{
            if( hasToken()) {
              return <ProfileEdit/>
            } else {
              console.log('没有token，去login')
              return <Redirect to="/login"></Redirect>
            }
          }}></Route> */}
        </Switch>
      </Router>
    </div>
  )
}

export default App
